<html ng-app="app">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../build/common/base.css" rel="stylesheet">
<link href="../../build/form/form.css" rel="stylesheet">
<link href="../../build/common/codeMirror.css" rel="stylesheet">
<script type="text/javascript" src="../../build/common/base.js"></script>
<script type="text/javascript" src="../../build/common/ngEdit.js"></script>
<script type="text/javascript" src="../../build/common/codeMirror.js"></script>
<script type="text/javascript" src="../../assets/js/common/custSql/uiDirective.js"></script>
<script type="text/javascript" src="../../assets/js/plugins/softable/Sortable-1.6.1.min.js"></script>
<script type="text/javascript" src="../../assets/js/plugins/sql/sql-formatter.min.js"></script>
<script type="text/javascript" src="../../assets/js/common/custSql/formCustSqlController.js"></script>
<script type="text/javascript" src="../../assets/js/common/tools/util.js"></script>
<style>
html {
	zoom: 0.8 !important;
}

td,tr {
	padding: 2px 5px !important;
	padding-top: 2px !important;
}
</style>
</head>
<body class="panel success" ng-controller="formCustSqlController">
	<div class="panel-heading" ng-if="!isSee">
		<button class="btn btn-primary fa-save" ng-click="saveData()">保存</button>
		<button class="btn btn-primary fa-save" ng-click="saveData(true)">保存并预览</button>
		<button class="btn btn-danger fa-close" onclick="javascript:$.Dialog.close(window);">关闭</button>
	</div>
	<form id="formCustSqlForm" name="form" method="post">
		<div class="col-sm-12">
			<div class="zoom12">
				<textarea class="form-control inline-block textarea" type="text" ui-codemirror broadcast="sql" height="200px" ng-model="data.sqlContent" ab-validate="{required:true}" ng-disabled="isSee"></textarea>
			</div>
			<div ng-show="!isSee" class="mt10">
				<button class="btn btn-primary ml5" ng-click="parseSql()">解析</button>
				<button type="button" class="btn btn-primary ml5" ng-click="addAliases()">添加别名</button>
				<button type="button" class="btn btn-primary ml5" ng-click="data.sqlContent = formatSql(data.sqlContent)">美化脚本</button>
				<button type="button" class="btn btn-primary ml5" ng-click="showHelp = !showHelp">帮助</button>
			</div>
			<div class="pl10 pt10 pb10" ng-if="!isSee && showHelp">
				您可以输入${xxx}作为参数变量,xxx参数可以从url地址传入,也可以从查询栏传入,优先使用查询栏的参数,例如
				<br />
				SELECT t1.`id` AS t1id,t1.`mz` AS t1mz FROM test t1 where t1.user_id = '${currentUserId}'
				<br />
				${currentUserId},${currentUserName},${curTime},${curDate},${curDateTime}
				<br />
				注意:
				<div class="red ml10" ng-if="!isSee">
					1. 尽量不要使用*全表查询
					<br />
					2. 暂只支持mysql,最好先在mysql工具写好sql后,再粘贴于此
					<br />
					3. 字段最好取一个别名,如果觉得麻烦可以点击添加别名按钮
					<br />
					4. ${xx}需要用单双引号包裹
					<br />
					5. 只能支持select查询
					<br />
					5. 数据库字段备注规则如下
					<br />
					<span class="ml10">5.1 备注 xxx 1:下拉项1,2:下拉项2,3:下拉项3 则会自动解析成下拉框控件</span>
					<br />
					<span class="ml10">5.2 备注 xxx dic:xxxx 则会自动解析成数据字典控件</span>
					<br />
					<span class="ml10">5.3 如果是date类型 则自动解析成日期控件 并且格式化参数为 yyyy-MM-dd</span>
					<br />
					<span class="ml10">5.4 如果是datetime类型 则自动解析成日期控件 并且格式化参数为 yyyy-MM-dd HH:mm:ss</span>
					<br />
					<br />
				</div>
			</div>
		</div>
		</div>
		<div class="form-group w100 inline-block ">
			<ul class="nav nav-tabs" role="tablist">
				<li role="presentation" class="active"><a href="#baseSetting" aria-controls="baseSetting" role="tab" data-toggle="tab" class=" fa fa-navicon">列表基础设置</a></li>
				<li role="presentation"><a href="#fieldsSetting" aria-controls="fieldsSetting" role="tab" data-toggle="tab" class=" fa fa-navicon">列表字段设置</a></li>
				<li role="presentation"><a href="#searchSetting" aria-controls="searchSetting" role="tab" data-toggle="tab" class=" fa fa-search">列表查询设置</a></li>
				<li role="presentation"><a href="#buttonSetting" aria-controls="buttonSetting" role="tab" data-toggle="tab" class=" fa fa-square pl10">列表功能按钮设置</a></li>
			</ul>
			<div class="tab-content">
				<div role="tabpanel" class="tab-pane o-x-s active" id="baseSetting">
					<custom-sql-base-setting></custom-sql-base-setting>
				</div>
				<div role="tabpanel" class="tab-pane o-x-s" id="fieldsSetting" ng-show="data.fieldsList.length>0">
					<custom-sql-fields-setting></custom-sql-fields-setting>
				</div>
				<div role="tabpanel" class="tab-pane o-x-s" id="searchSetting" ng-show="data.fieldsList.length>0">
					<custom-sql-search-setting></custom-sql-search-setting>
				</div>
				<div role="tabpanel" class="tab-pane o-x-s" id="buttonSetting" ng-show="data.fieldsList.length>0">
					<custom-sql-button-setting></custom-sql-button-setting>
				</div>
				<div class="t-a-c hd50 lh50 f18" ng-show="!data.fieldsList || data.fieldsList.length==0">请先解析SQL</div>
			</div>
		</div>
	</form>
	<div ng-include="'setting/openSetting.html'"></div>
</body>
</html>
